import React, { useState } from 'react'
import { Table, Tooltip, Space, Button, Flex } from 'antd';
import type { TableColumnsType, TableProps } from 'antd';
import { updateafter, getafterdetail } from '../../../../request/api'
import Pop_up_layers from './Pop_up_layers'


export default function To_be_reviewed(props) {
    const { afterdata, getall } = props

    const [model_type, setmodel_type] = useState(false)
    const updatmodel_type = (item: boolean) => {
        setmodel_type(item)
    }

    type TableRowSelection<T extends object = object> = TableProps<T>['rowSelection'];
    const columns: TableColumnsType = [
        { title: '商品订单时间', dataIndex: 'buy_time' },
        { title: '团长', dataIndex: 'billtype' },
        { title: '提现金额', dataIndex: 'commission' },
        { title: '提现方式', dataIndex: 'commission_tixian' },
        { title: '实际到账金额', dataIndex: 'commission' },
        { title: '对应订单号', dataIndex: 'goodsid' },
        { title: '状态', dataIndex: 'commission_state' },
        { title: '到账时间', dataIndex: 'daozhangshijian' },
    ];




    const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);

    // 数据渲染
    const dataSource = afterdata.filter(ele => ele.billtype == true).map((item) => ({
        key: item._id,
        buy_time: item.goodsid.buy_time,
        billtype: item.groupsid.name,
        commission: item.goodsid.commission,
        goodsid: item.After_sales_managementid._id,
        commission_state: item.goodsid.commission_state,
        daozhangshijian: item.goodsid.daozhangshijian,
        commission_tixian:item.goodsid.commission_tixian
    }));


    // 选择项
    const onSelectChange = (newSelectedRowKeys: React.Key[]) => {
        // console.log('selectedRowKeys changed: ', newSelectedRowKeys);
        setSelectedRowKeys(newSelectedRowKeys);
        getid(newSelectedRowKeys)
    };
    const rowSelection: TableRowSelection = {
        selectedRowKeys,
        onChange: onSelectChange,
    };
    const hasSelected = selectedRowKeys.length > 0;




    const [componentSize, setComponentSize] = useState<SizeType | 'default'>('default');
    const onFormLayoutChange = ({ size }: { size: SizeType }) => {
        setComponentSize(size);
    };





    return (
        <div>
            <Flex gap="middle" vertical>
                {/* <Pop_up_layers model_type={model_type} updatmodel_type={updatmodel_type} after_data={after_data}></Pop_up_layers> */}
                <Table rowSelection={rowSelection} columns={columns} dataSource={dataSource} />
            </Flex>
        </div>
    )
}
